fix(rees): stop dropping added ++-prefixed lines in the duplication scan#2571
fix(rees): stop dropping added ++-prefixed lines in the duplication scan#2571ultrahighsuper wants to merge 1 commit into
++-prefixed lines in the duplication scan#2571Conversation
… scan extractAddedBlocks skipped any in-hunk line starting with `+++` as a "file header", but the `+++ b/file` header only appears in the patch preamble, which the `!inHunk` guard already drops. Inside a hunk, `+++…` is an added line whose content begins with `++` (e.g. a pre-increment `++x;`): the skip dropped that real line from the block AND shifted every following added line's number down by one (it never advanced the new-file counter). Remove the redundant skip so such lines are normalized and numbered like any other added line.
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-02 09:10:28 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 4 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
JSONbored
left a comment
There was a problem hiding this comment.
Merge conflicts, a previous PR already handled this.
This branch has conflicts that must be resolved
Use the [web editor](https://github.com/JSONbored/gittensory/pull/2571/conflicts) or the command line to resolve conflicts before continuing.
review-enrichment/src/analyzers/duplication-scan.ts
Summary
extractAddedBlocksinreview-enrichment/src/analyzers/duplication-scan.tsparses a unified diff into blocks of added significant lines with their new-file line numbers (used to locate copy-paste duplication). Inside the hunk loop it had:The
+++skip is meant to drop the+++ b/filediff header — but that header only appears in the patch preamble, before the first@@, which theif (!inHunk) continue;guard right above already drops. So inside a hunk, a line starting with+++is never a header: it is an added line whose content begins with++(e.g. a pre-increment statement++counterValueForLoop;→ patch line+++counterValueForLoop;).The stray skip therefore (a) drops that real added line from the block, and (b) since it
continues beforenewLine++, shifts every following added line's number down by one. Downstream,scanDuplication→longestSharedRunreportsDuplicationFinding.line/sourceLineoff by one for any run following such a line, and a copy-pasted run that starts with a++-line can be missed.Fix: remove the redundant
+++skip so+++…lines fall through to the normal+handling (normalized and counted). Headers remain handled by the!inHunkguard.Note: this is the only analyzer where the
+++skip is redundant — the others (secret-scan,redos, etc.) don't trackinHunkand use the marker to skip preamble headers, so they have a different structure and are out of scope here.No linked issue: small, self-contained diff-parsing fix in one helper; per this repo's
linkedIssuePolicy: preferred, a direct PR with this rationale is appropriate.Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm --prefix review-enrichment run build(tsc clean)npm --prefix review-enrichment run test— theduplication-scansuite passes (36 tests) with a new regression test asserting an added++counterValueForLoop;line is kept and the block's line numbers stay[10, 11, 12](not[10, 11]). The test was confirmed to FAIL against the unpatched code (the line was dropped and numbers shifted).If any required check was skipped, explain why:
review-enrichment/src; it adds/changes no analyzer, soanalyzer-metadata.jsonis unaffected. Codecov'ssrc/**patch gate does not apply toreview-enrichment/**; this package's ownnode --testsuite covers it.Safety
Notes
extractAddedBlocks("@@ -1,0 +10,3 @@\n+++counterValueForLoop;\n+const secondSignificantLineHere = makeValue(2)\n+const thirdSignificantLineHere = makeValue(3)")previously returned one block withlineNos [10, 11](the++line dropped, following lines shifted); it now returnslineNos [10, 11, 12]with all three lines.